var prefix = jsctx + "/tenantTransfer";

var addTenantTransfer = (function () {
    function init() {
        validateRule();
    };

    var isajaxsend = true;

    function save() {

        if (isajaxsend) {
            var formData = new FormData($("#frmTenantTransfer")[0]);
            $.ajax({
                cache: true,
                type: "POST",
                url: prefix + "/saveOrUpdateTenantTransfer",
                data: formData,
                processData: false,
                contentType: false,
                async: false,
                beforeSend: function () {
                    isajaxsend = false
                },
                error: function (request) {
                    isajaxsend = true
                    parent.layer.alert("Connection error");
                },
                success: function (data) {
                    if (data.status == 200) {
                        isajaxsend = true
                        parent.layer.msg("操作成功");
                    } else {
                        isajaxsend = true
                        parent.layer.alert(data.message)
                    }

                }
            });
        }
    }

    function validateRule() {
        var icon = "<i class='fa fa-times-circle'></i> ";
        $("#frmTenantTransfer").validate({
            rules: {
            },
            messages: {
            },
            submitHandler: function (form) {
                save();
            }
        })
    }

    return {
        init: init
    };
})();
